package com.yun.datastructure.map.hashmap.leetcode;

public class Leetcode387 {
    public int firstUniqChar(String s) {
        int[] map=new int[26];
        int sLen=s.length();
        char[] chars = s.toCharArray();
        for (char ch : chars) {
            map[ch-97]++;
        }
        for (int i = 0; i < sLen; i++) {
            char ch=chars[i];
            if(map[ch-97]==1){
                return i;
            }
        }
        return -1;
    }
}
